package com.pds.web.exit.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.exit.entity.PdsOrganizationReset;
import com.pds.web.exit.service.PdsOrganizationResetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 机构重置详情
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-02-06
 */
@RestController
@RequestMapping("/organizationReset")
@Api(tags="机构重置详情")
public class PdsOrganizationResetController extends BaseController{
    @Resource
    private PdsOrganizationResetService pdsOrganizationResetService;

    /**
     * 分页查询机构重置详情
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询机构重置详情")
    @GetMapping("/page")
    public TableDataInfo pageOrganizationReset(PdsOrganizationReset pdsOrganizationReset){
        startPage();
        List<PdsOrganizationReset> list = pdsOrganizationResetService.selectList(pdsOrganizationReset);
        return getDataTable(list);
    }

    /**
     * 查询机构重置详情列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询机构重置详情列表")
    @GetMapping("/list")
    public R<List<PdsOrganizationReset>> listOrganizationReset(PdsOrganizationReset pdsOrganizationReset){
        List<PdsOrganizationReset> list = pdsOrganizationResetService.selectList(pdsOrganizationReset);
        return R.ok(list);
    }

    /**
     * 根据ID查询机构重置详情
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("机构重置详情")
    @GetMapping("/queryById/{id}")
    public R<PdsOrganizationReset> queryOrganizationResetById(@PathVariable("id")Long id) {
        return R.ok(pdsOrganizationResetService.queryById(id));
    }

    /**
     * 创建机构重置详情
     * @param pdsOrganizationReset 记录
     * @return 机构重置详情
     */
    @ApiOperation("创建机构重置详情")
    @PostMapping("/add")
    public R<PdsOrganizationReset> addOrganizationReset(@RequestBody PdsOrganizationReset pdsOrganizationReset){
        return R.ok(pdsOrganizationResetService.insert(pdsOrganizationReset));
    }

    /**
     * 修改机构重置详情
     * @param pdsOrganizationReset 记录
     * @return 成功标识
     */
    @ApiOperation("修改机构重置详情")
    @PutMapping("/edit")
    public R<Boolean> editOrganizationReset(@RequestBody PdsOrganizationReset pdsOrganizationReset){
        return R.ok(pdsOrganizationResetService.update(pdsOrganizationReset));
    }

    /**
     * 根据ID删除机构重置详情
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除机构重置详情")
    @DeleteMapping("/delete")
    public R<Boolean> deleteOrganizationResetById(@RequestParam Long id) {
        return R.ok(pdsOrganizationResetService.deleteById(id));
    }
}